/**
 * @ClassName LC2595
 * @Author ykx
 * @Date 2024/3/22 7:51
 * @Version 1.0
 */
public class LC2595 {
    public int[] evenOddBit(int n) {
        int[] nums = new int[2];
        int even = 0;
        int odd = 0;
        StringBuilder stringBuilder = new StringBuilder("");
        while (n != 0) {
            stringBuilder.append(n % 2);
            n = n / 2;
        }
        for (int i = 0; i < stringBuilder.length(); i++) {
            if (stringBuilder.charAt(i) == '1') {
                if (i % 2 == 0) {
                    even++;
                } else {
                    odd++;
                }
            }
        }
        nums[0] = even;
        nums[1] = odd;
        return nums;

    }
}
